﻿
@{
    ViewBag.Title = "TatisticWorkload";
    Layout = "~/Views/Shared/_Index.cshtml";
}
<script>
    var Editing_ysList = []; //编辑域中的人员
    $(function () {
        $('#zls').click(function () {
            var initIdSelected = "";
            $.each(Editing_ysList,
                function () {
                    initIdSelected += this.id + ",";
                });
            $.modalOpen({
                id: "StaffCorrelation",
                title: "选择治疗师",
                url: "/SystemManage/SysStaff/Selector?single=true&isContansChildOrg=false&callbackType=json&dutyCode=RehabDoctor&initIdSelected=" + initIdSelected,
                showleftlalbel: false,
                width: "650px",
                height: "570px",
                callBack: function (iframeId) {
                    top.frames[iframeId].AcceptClick(function (data) {
                        staffTreeCallback(data);
                    });
                }
            });
        });

        init();
        gridList();
    });

    //人员树 选择 回调
    function staffTreeCallback(treeSeleData) {
        Editing_ysList = [];
        var zlsNames = "";
        $.each(treeSeleData, function () {
            zlsNames += this.text + ",";
            Editing_ysList.push({ id: this.id, gh: this.value, Name: this.text, ks: this.Ex1, ksmc: this.Ex2 });
        })
        if (zlsNames.length > 0) {
            zlsNames = zlsNames.substring(0, zlsNames.length - 1);
        }

        $('#zls').val(zlsNames);
    }

    function init() {
        var date = new Date;
        //年份
        $("#Year").newtouchBindSelect({
            datasource: function () {
                var resultObjArr = new Array();
                if (top.clients.yearArr && top.clients.yearArr.length) {
                    $.each(top.clients.yearArr, function () {
                        resultObjArr.push({ id: this, text: this });
                    });
                }
                return resultObjArr;
            },
            selectedValue: 1900 + date.getYear(),
        });
        //月份
        $("#Month").newtouchBindSelect({
            datasource: function () {
                var resultObjArr = new Array();
                if (top.clients.monthArr && top.clients.monthArr.length) {
                    $.each(top.clients.monthArr, function () {
                        resultObjArr.push({ id: this, text: parseInt(this) < 10 ? "0" + this : this });
                    });
                }
                return resultObjArr;
            },
            selectedValue: date.getMonth() + 1,
        });

        $("#ks").newtouchBindSelect({
            datasource: function () {
                var resultObjArr = new Array();
                $.each(top.window.clients.sysDepartList, function (idx, val) {
                    resultObjArr.push({ id: val.Code, text: val.Name });
                });
                return resultObjArr;
            }
        });
    }

    function gridList() {
        var $gridList = $("#HisgridList");
        $gridList.dataGrid({
            height: $(window).height() - 165,
            url: "/TherapeutistManage/TherapeutistCompleteList/GetStaffReport",
            postData: getSearchPostData(),
            colModel: [
                { label: "主键", name: "id", hidden: true, key: true },
                { label: '工号', name: 'ysgh', width: 80, align: 'left' },
                { label: '姓名', name: 'NAME', width: 150, align: 'left' },
                {
                    label: '治疗工时(H)', name: 'zlgs', width: 100, align: 'left', formatter: function (cellvalue) {
                        return (cellvalue / 60).toFixed(2);
                    }
                },
                {
                    label: '非治疗工时(H)', name: 'fzlgs', width: 100, align: 'left', formatter: function (cellvalue) {
                        return (cellvalue / 60).toFixed(2);
                    }
                },
                {
                    label: '总工时(H)', name: 'zgs', width: 100, align: 'left', formatter: function (cellvalue) {
                        return (cellvalue / 60).toFixed(2);
                    }
                },
                {
                    label: '治疗占比(非治疗/治疗)', name: 'zlzb1', width: 150, align: 'left', formatter: function (cellvalue) {
                        return (cellvalue* 100).toFixed(2)+ "%";
                    }
                },
                {
                    label: '治疗占比(治疗/总工时)', name: 'zlzb2', width: 150, align: 'left', formatter: function (cellvalue) {
                        return (cellvalue * 100).toFixed(2) + "%";
                    }
                }
            ],
            //pager: "#gridPager",
            //sortname: 'desc',
            //rowNum: '10',
            viewrecords: true
        });

        $("#btn_search").click(function () {
            $gridList.jqGrid('setGridParam',
                {
                    postData: getSearchPostData(),
                    url: "/TherapeutistManage/TherapeutistCompleteList/GetStaffReport"
                }).trigger('reloadGrid');
        });
    }

    function getSearchPostData() {
        var postData = {};
        postData.year = $('#Year').val();
        postData.month = $('#Month').val();
        postData.ysgh = "";
        if (!postData.year || !postData.month) {
            return;
        }
        if (Editing_ysList.length > 0) {
            postData.ysgh = Editing_ysList[0].gh;
        }
        return postData;
    }
</script>
<form id="form1">
    <div class="panel panel-default" style="margin-top:5px;">
        <div class="panel-heading navb-bg">
            筛选条件
        </div>
        <div style="padding: 2px;">
            <table class="form">
                <tr>
                    <td class="formTitle">年份：</td>
                    <td class="formValue">
                        <select id="Year" class="form-control">
                            <option value="-1">===请选择===</option>
                        </select>
                    </td>
                    <td class="formTitle">月份：</td>
                    <td class="formValue">
                        <select id="Month" class="form-control">
                            <option value="-1">===请选择===</option>
                        </select>
                    </td>
                    <th class="formTitle">治疗师：</th>
                    <td class="formValue">
                        <input id="zls" type="text" class="form-control" />
                    </td>
                    <td class="formValue" colspan="2">
                        <input type="button" id="btn_search" class="btn btn-primary" style="width: 50px; margin-left: 40px;" value="查询" />
                    </td>
                </tr>
            </table>
        </div>
    </div>
</form>
<div class="gridPanel">
    <table id="HisgridList"></table>
    @*<div id="gridPager"></div>*@
</div>
@*@Html.Partial("_BottomButtonsView", new Newtouch.HIS.Web.Core.Models.BottomButtonViewModel
    {
        ShowKeyList = new int[] { 9 },
        F9Text = "导出"
    })*@


